#!/bin/env python
# -*- coding:utf-8
"""
@author:xingz
@file:chromosome.py
@time:2022/05/29
"""
from __future__ import annotations

from abc import abstractmethod, ABC
from typing import *

T = TypeVar('T', bound='Chromosome')


# Base class for all chromosomes;all methods must be overridden
class Chromosome(ABC):
    @abstractmethod
    def fitness(self) -> float:
        pass

    @classmethod
    @abstractmethod
    def random_instances(cls: Type[T]) -> T:
        pass

    @abstractmethod
    def crossover(self: T, other: T) -> Tuple[T, T]:
        pass

    @abstractmethod
    def mutate(self) -> None:
        pass

